import { io } from 'socket.io-client';
 
let socket;
 
export function socketInstance(token, userId) {
  socket = io("http://localhost:33000", {
    transports: ['websocket'],//默认是HTTP轮训，设置这个就是为ws
    upgrade: false,//关闭自动升级ws，开启的话监听的通过消息会收不到
    query: { //通过参数的形式传参
      token: token,
      userId: userId,
    },
  });
  return socket;
}

export function getSocket() {
  return socket;
}